import java.io.*;
public class self_describing {
    public static void main (String[] args) throws IOException{
        if (args.length<1) throw new RuntimeException ("not enough arguments");
        if (args.length>1) throw new RuntimeException ("too many arguments");
        BufferedReader reader = new BufferedReader (new FileReader (new File (args[0])));
        String line;
        while ((line = reader.readLine()) != null){
            boolean selfDescribing = true;
            for (int i = 0;i<line.length();i++){
                int amount = 0;
                int howMany = Character.getNumericValue(line.charAt(i));
                for (int j = 0;j<line.length();j++){
                    if (i == Character.getNumericValue(line.charAt(j))) amount++; 
                }
                if (howMany != amount) {
                    selfDescribing = false;
                    break;
                }
            }
            if (selfDescribing == true) System.out.println("1");
            else                        System.out.println("0");
        }
    }
}
